package cn.kgc.itrip.controller;

import cn.kgc.itrip.common.DtoUtil;
import cn.kgc.itrip.common.Page;
import cn.kgc.itrip.dto.Dto;
import cn.kgc.itrip.service.SearchService;
import cn.kgc.itrip.vo.ItripHotelVO;
import cn.kgc.itrip.vo.hotel.SearchHotCityVO;
import cn.kgc.itrip.vo.hotel.SearchHotelVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @program: love_travel
 * @description: 酒店查询
 * @author: Mr.Wang
 * @create: 2020-03-25 17:06
 **/

@RestController
@RequestMapping("/api/hotellist")
public class HotelListController {

    @Resource
    private SearchService searchService;

    /**
     * solr的三级酒店查询
     * @param vo
     * @return
     */
    @PostMapping(value = "/searchItripHotelPage",produces = "application/json")
    public Dto<Page<ItripHotelVO>> searchItripHotelPage(@RequestBody SearchHotelVO vo){
        Dto dto = null;
        try {
            dto = searchService.findItripHotelPage(vo);
        } catch (Exception e) {
            e.printStackTrace();
            dto = DtoUtil.returnFail("系统异常,获取失败","20001");
        }
        return dto;
    }


    /**
     * 根据热门城市查询酒店
     * @param vo
     * @return
     */
    @PostMapping(value = "/searchItripHotelListByHotCity",produces = "application/json")
    public Dto searchItripHotelListByHotCity(@RequestBody SearchHotCityVO vo){
        Dto dto=null;
        dto=searchService.findHotelListByHotCity(vo);
        return dto;
    }
}
